# 打开文件，不存在的文件
import time

# f = open("D:/不存在的文件名","w",encoding="UTF-8")
# write 写入
# f.write("hello world!")   # 内容写入内存中
# f.flush()                 # 将内存中积攒的内容，写入到硬盘的文件
#time.sleep(500000)
# flush 刷新 自带close功能的
# 打开一个存在的文件
# f = open("D:/xiao文件名","a",encoding="UTF-8")
# # write写入，flush刷新
# f.write("\n88")
# f.flush()
# close关闭
#f.close()


fr = open("D:/bill.txt", "r", encoding="UTF-8")
fw = open("D:/bill.txt.bak", "w", encoding="UTF-8")
for line in fr:
    line = line.strip()  # 将字符串开头和结尾的空格和换行都处理掉
    if line.split(",")[4] == "测试":
        continue      # 满足测试就跳过了，进入下一次循环，这一次后面的内容分就跳过了
    fw.write(line)  # fw.write 将内容写出去
    fw.write("\n")  # 要手动写出换行符
fr.close()
fw.close()


















